import request from '@/utils/request'

// 查询公告列表
export function listNotice(query) {
  return request({
    url: '/api/message/list',
    method: 'get',
    params: {
      pageNum: query.pageNum,
      pageSize: query.pageSize,
      title: query.title,
      status: query.status,
      type: query.type,
      userId: query.userId
    }
  })
}

// 查询公告详细
export function getNotice(noticeId) {
  return request({
    url: '/api/notice/' + noticeId,
    method: 'get'
  })
}

// 新增公告
export function addNotice(data) {
  return request({
    url: '/api/message/notice',
    method: 'post',
    data: data
  })
}

// 修改公告
export function updateNotice(data) {
  return request({
    url: '/api/message/update',
    method: 'put',
    data: data
  })
}

// 删除公告
export function delNotice(id) {
  return request({
    url: '/api/message/' + id,
    method: 'delete'
  })
}

// 批量删除公告
export function delNotices(ids) {
  return request({
    url: '/api/message/batch/' + ids,
    method: 'delete'
  })
}

// 发布公告
export function publishNotice(id) {
  return request({
    url: '/api/message/publish/' + id,
    method: 'put'
  })
}
